package com.skhu.as.dao;

import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;

import com.skhu.as.domain.RequestType;
import com.skhu.as.mapper.RequestTypeM;

public class RequestTypeD {

	private JdbcTemplate jdbcTemplate;

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
	
	public List<RequestType> getRequestTypeList(){
		String sql = "SELECT request_type_no, request_type FROM request_type";
		List<RequestType> requestTypeList = jdbcTemplate.query(sql, new RequestTypeM());
		return requestTypeList;
	}
	
	public int deleteAllRequestType(){
		String sql = "DELETE FROM request_type";
		int result = jdbcTemplate.update(sql);
		return result;
	}
	
	public int getRequestTypeMaxNo(){
		String sql = "SELECT MAX(request_type_no) FROM request_type";
		int result = jdbcTemplate.queryForInt(sql);
		return result;
	}
	
	public int insertRequestType(int requestTypeMaxNo, String requestTypeString){
		String sql = "INSERT INTO request_type VALUES (?, ?)";
		Object[] param = new Object[]{
			requestTypeMaxNo,
			requestTypeString
		};
		int result = jdbcTemplate.update(sql, param);
		return result;
	}
	
	
}
